package com.assistant.controller;

import com.assistant.pojo.AddressPoster;
import com.assistant.pojo.PostPackage;
import com.assistant.service.PostPackageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("package")
public class PostPackageController {
    @Autowired
    private PostPackageService postPackageService;

    @PostMapping("/insert")
    public int insertPostPackageC(@RequestBody PostPackage postPackage) {
        return postPackageService.insertPostPackage(postPackage);
    }

    @PutMapping("/update")
    public int updatePackageC(@RequestBody PostPackage postPackage) {
        return postPackageService.updatePostPackage(postPackage);
    }


    @PutMapping("/cancle/{id}")
    public int deletePackageC(@PathVariable("id") Long id) {
        return postPackageService.cancelPostPackage(id);
    }

    @GetMapping("/select")
    public List<AddressPoster> selectAllC() {
        return postPackageService.showAllPostPackage();
    }

    @PostMapping("/selectBy")
    public List<AddressPoster> selectPostPackageByxxC(@RequestBody Map<String,String> map) {
        System.out.println(map);
        return postPackageService.selectPostPackageByx(map);
    }

    @PutMapping("/update/{id}/{address_id}")
    public int updateGetterMsgC(@PathVariable("id") Long id, @PathVariable("address_id") Long address_id) {
        return postPackageService.updateGetterMsg(id, address_id);
    }

    @GetMapping("/updateStatus/{id}/{status}")
    public int updateStatus(@PathVariable("id") Integer id,@PathVariable("status") Integer status){
        return postPackageService.updateStatus(id,status);
    }

    @DeleteMapping("/delete/{id}")
    public int delete(@PathVariable("id") Integer id){
        return postPackageService.deletePackage(id);
    }
}
